<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #demo{
            /* 保留换行和空格 */
            /* white-space: pre; */
        }
    </style>
</head>
<body>
    <div id="demo"></div>
</body>
<script>
    // 了解
    // \s 匹配空白字符 (空格 换行符(\n) 回车符(\r) 制表符(\t) 垂直制表符(\v) => 在浏览器中会被解析为空格)     [ \n\r\t\v]
    // \s 匹配非空白字符  [^ \n\r\t\v]
    // .  除换行符以外的其他字符  [^\n]

    var demo = document.getElementById("demo");

    demo.innerHTML = `good good\nstudy ,\r day\t day  up`;

    var reg = /\s/g;
    console.log("good good\nstudy ,\r day\t day \v up".match(reg)); 


</script>
</html>